<?php
namespace App\Listener;

use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Event\Annotation\Listener;

/**
 * @Listener 
 */
class UserUserListener implements ListenerInterface
{
    public function listen(): array
    {
        return [
            \App\Event\User\CreateEvent::class,
        ];
    }
    
    // 更新上级关系
    public function process($event)
    {
        // 否有上级
        if($user = $event->toUser)
        {
            $event->user->setUser($user);
        }
    }
}